import { Injectable } from '@angular/core';
import { HttpClient, HttpParams, HttpHeaders } from '@angular/common/http';


@Injectable()
export class UserService {

  private apiUrl = 'http://xcms.0715ym.com/admin/admin';

  constructor(private http: HttpClient,
  ) { }

  getUser() {
    return this.http.get(this.apiUrl+'/get_user',{
      withCredentials: true
    });
  }

  getUserLog() {
    return this.http.get(this.apiUrl+'/get_log',{
      withCredentials: true
    });
  }

  updateUser(formData) {
    let params = new HttpParams;
    for(const i in formData){
      params = params.set(i,formData[i]); 
    }

    return this.http.post(this.apiUrl + '/update_user', params.toString(), {
      headers: new HttpHeaders().set('content-Type', 'application/x-www-form-urlencoded'),
      withCredentials: true
    })
  }
  
}
